home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic 4 Database How-To
/
Visual Basic 4 Database - How-to (The Waite Group)(1995).iso
/
authors.fr_
/
authors.fr
Wrap
Text File
|
1995-04-01
|
5KB
|
165 lines
VERSION 4.00
Begin VB.Form frmAuthors
Caption = "Author Birth Range"
ClientHeight = 1575
ClientLeft = 1815
ClientTop = 1515
ClientWidth = 4185
Height = 1980
Left = 1755
LinkTopic = "Form1"
ScaleHeight = 1575
ScaleWidth = 4185
Top = 1170
Width = 4305
Begin VB.TextBox txtEnd
Height = 285
Left = 1200
TabIndex = 5
Top = 960
Width = 1215
End
Begin VB.TextBox txtStart
Height = 285
Left = 1200
TabIndex = 2
Top = 360
Width = 1215
End
Begin VB.CommandButton cmdQuit
Caption = "Quit"
Height = 495
Left = 2760
TabIndex = 1
Top = 840
Width = 1215
End
Begin VB.CommandButton cmdReport
Caption = "Run Report"
Default = -1 'True
Height = 495
Left = 2760
TabIndex = 0
Top = 240
Width = 1215
End
Begin MSComDlg.CommonDialog cdOpenReport
Left = 600
Top = 1200
_version = 65536
_extentx = 847
_extenty = 847
_stockprops = 0
defaultext = "rpt"
dialogtitle = "Select Crystal Report"
filter = "Reports (*.rpt)|*.rpt|All Files (*.*)|*.*"
initdir = "c:\vb\report"
End
Begin VB.Label Label2
Caption = "End Year:"
Height = 255
Left = 240
TabIndex = 4
Top = 960
Width = 855
End
Begin VB.Label Label1
Caption = "Start Year:"
Height = 255
Left = 240
TabIndex = 3
Top = 360
Width = 855
End
Begin Crystal.CrystalReport CrystalReport1
Left = 0
Top = 1200
_extentx = 741
_extenty = 741
_stockprops = 0
reportfilename = ""
destination = 0
windowleft = 100
windowtop = 100
windowwidth = 490
windowheight = 300
windowtitle = ""
windowborderstyle= 2
windowcontrolbox= -1 'True
windowmaxbutton = -1 'True
windowminbutton = -1 'True
copiestoprinter = 1
printfilename = ""
printfiletype = 0
selectionformula= ""
groupselectionformula= ""
connect = ""
username = ""
End
End
Attribute VB_Name = "frmAuthors"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
Option Explicit
Private Sub cmdQuit_Click()
End
End Sub
Private Sub cmdReport_Click()
Dim selCriteria As String
Static saveDir As String
'Check for errors in the input year boxes
If (Val(txtStart.Text) > Val(txtEnd.Text)) And Val(txtEnd.Text) Then
MsgBox "Start year must be before End year."
Exit Sub
End If
If Val(txtStart.Text) And Val(txtStart.Text) < 1850 And Val(txtStart.Text) > Year(Now) Then
MsgBox "Please enter a start year in the range 1850 to " & Year(Now)
Exit Sub
End If
If Val(txtEnd.Text) And Val(txtEnd.Text) < 1850 And Val(txtEnd.Text) > Year(Now) Then
MsgBox "Please enter an ending year in the range 1850 to " & Year(Now)
Exit Sub
End If
'Get the file to print using Common Dialog
cdOpenReport.InitDir = saveDir
cdOpenReport.ShowOpen
'Let's be nice and "remember" the directory for the next use
saveDir = cdOpenReport.FileName
If Len(cdOpenReport.FileName) Then
'Adding the data to the control
CrystalReport1.Destination = 0 'To Window
CrystalReport1.ReportFileName = cdOpenReport.FileName
If Len(txtStart.Text) And Len(txtEnd.Text) Then
'Year range entered
selCriteria = "{Authors.Year Born} in " & txtStart.Text & " to " & txtEnd.Text
ElseIf Len(txtStart.Text) And Len(txtEnd.Text) = 0 Then
'Only starting year selected
selCriteria = "{Authors.Year Born} >= " & txtStart.Text
ElseIf Len(txtStart.Text) = 0 And Len(txtEnd.Text) Then
selCriteria = "{Authors.Year Born} <= " & txtEnd.Text
Else
'Both boxes are emtpy; don't limit range
selCriteria = ""
End If
CrystalReport1.SelectionFormula = selCriteria
'Run the report
CrystalReport1.Action = 1
Else
'User pressed Cancel in Common Dialog
MsgBox "No report file selected."
End If
End Sub
Private Sub Form_Load()
'Move the form to the lower right of screen
Me.Move Screen.Width - 1.1 * Me.Width, Screen.Height - 1.25 * Me.Height
End Sub